package com.kaishengit.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import com.kaishengit.core.dao.BaseDao;
import com.kaishengit.pojo.Chance;

@Repository
public class ChanceDao extends BaseDao<Chance, Integer>{

	public Chance findByName(String chancename) {
			String hql = "from Chance where chancename = ?";
			Query query = getSession().createQuery(hql);
			query.setParameter(0, chancename);
			return  (Chance) query.uniqueResult();
	}
@SuppressWarnings("unchecked")
	public List<Chance> findAll(String  state) {
		String hql = "from Chance where state = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0,state);
		List<Chance> cList = new ArrayList<Chance>();
		cList = query.list();
		System.out.println("cList : " + cList.size());
		return cList;
	}
	
	
	@SuppressWarnings("unchecked")
	public List<Chance> findAllId(int id) {
		String hql = "from Chance where chanceitemid = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0,id);
		List<Chance> cList11 = new ArrayList<Chance>();
		cList11 = query.list();
		System.out.println("cList : " + cList11.size());
		return cList11;
	}

	@SuppressWarnings("unchecked")
	public List<Chance> findAllId1(int id1) {
		String hql = "from Chance where employeeid = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0,id1);
		List<Chance> cList11 = new ArrayList<Chance>();
		cList11 = query.list();
		System.out.println("cList : " + cList11.size());
		return cList11;
	}
	@SuppressWarnings("unchecked")
	public List<Chance> findAllId1(Chance chance) {
		String hql = "from Chance where createtime = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0,chance);
		List<Chance> cList1 = new ArrayList<Chance>();
		cList1 = query.list();
		System.out.println("cList : " + cList1.size());
		return cList1;
		
	}

}
